package com.szrt.department;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class DepartmentServlet extends HttpServlet {
	
	private static final long serialVersionUID = -2109985798602704979L;

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		
		//0 此处的代码可以解决乱码问题
		request.setCharacterEncoding("utf-8");
		
		//1 拿前台提交过来的值  request
		String departmentName = request.getParameter("departmentName");
		String departmentCode = request.getParameter("departmentCode");
		
		System.out.println(departmentCode);
		System.out.println(departmentName);
		
		
		//2 把这个值显示到success.jsp  先放值  
		request.setAttribute("departmentName", departmentName);
		request.setAttribute("departmentCode", departmentCode);
		
		//3 往前台页面走 路径问题的重点： 以/开头  WebContent
		//  第一个斜杠  = 这个路径  WebContent/
		//WebContent/department/success.jsp
		request.getRequestDispatcher("/department/success.jsp").forward(request, response);
		
	}

}
